Skip to content

Comments

Speech to speech: Mute functionality#5688

Open
pranavjoshi001 wants to merge 9 commits intomicrosoft:mainfrom
pranavjoshi001:feature/s2s-mute
Open

Speech to speech: Mute functionality#5688
pranavjoshi001 wants to merge 9 commits intomicrosoft:mainfrom
pranavjoshi001:feature/s2s-mute

Conversation

@pranavjoshi001
Copy link
Contributor

@pranavjoshi001 pranavjoshi001 commented Feb 5, 2026

Changelog Entry

  • Added mute/unmute functionality for speech-to-speech with silent chunks to keep server connection alive, in PR #5688, by @pranavjoshi

Description

This PR adds mute/unmute functionality for the Speech-to-Speech (S2S) feature as core API only, without UI changes. When muted, the microphone is turned off (browser indicator disappears) but silent audio chunks continue to be sent to keep the server connection alive. This prevents connection timeouts while allowing consumers to implement their own mute UI.

Design

The mute functionality works at multiple levels:

  1. AudioWorklet Level:

    • Added MUTE and UNMUTE commands
    • When muted, the processor generates silent (all zeros) Int16 audio chunks instead of real audio data
    • This keeps chunks flowing at the same interval to maintain the server connection
  2. useRecorder Hook (useRecorder.ts):

    • Added mute() function that:
      • Sends MUTE command to the worklet
      • Disconnects the source node from the audio graph
      • Stops all MediaStream tracks (turns off browser mic indicator)
    • Returns an unmute() function that:
      • Sends UNMUTE command to the worklet
      • Re-acquires the microphone via getUserMedia
      • Reconnects the source node to the audio graph
  3. VoiceRecorderBridge (VoiceRecorderBridge.tsx):

    • Wires the mute function to the voice state machine
    • When voice state transitions to muted, calls mute() and stores the unmute function
    • When voice state transitions back to listening, calls the stored unmute function
  4. Redux Actions & Hooks:

    • Added muteVoiceRecording and unmuteVoiceRecording Redux actions
    • Exposed useMuteVoice and useUnmuteVoice hooks for consumers

Specific Changes

  • Added MUTE and UNMUTE command handling in AudioWorklet processor to generate silent chunks when muted
  • Added mute function to useRecorder.ts hook that disconnects audio and stops MediaStream while continuing to send silent chunks
  • Updated VoiceRecorderBridge.tsx to handle mute/unmute based on voice state changes
  • Added muteVoiceRecording.ts and unmuteVoiceRecording.ts Redux actions
  • Updated voiceActivity.ts reducer to handle VOICE_MUTE_RECORDING and VOICE_UNMUTE_RECORDING actions
  • Added useMuteVoice.ts and useUnmuteVoice.ts hooks and exported them from API, component, and bundle packages
  • Added unit tests for mute functionality in useRecorder.spec.tsx
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant